package com.xm.spider;

import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;

import java.io.IOException;

public class JsoupExample {
    public static void main(String[] args) throws IOException {
        Document document = Jsoup.connect("http://example.com").get();
        Elements elements = document.select("a[href]");
        for (Element element : elements) {
            System.out.println(element.attr("href"));
            System.out.println(element.text());
        }
    }
}
